/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
/**
 *
 * @author Elias Mendoza
 */
@Entity
@Table(name="grupo_sensor")
public class GrupoSensor implements Serializable{
  @Id
  @GeneratedValue(strategy= GenerationType.IDENTITY)
  private int id;
  @Column(nullable=false)
  private char sensor;
  //********Estableciendo la relacion de M:1 entre grupo_sensor y grupo (muchos grupo_sensor un grupo)
  @JoinColumn(name="id_grupo",referencedColumnName="id",nullable=false)
  @ManyToOne
  private Grupo grupo;
  //**************************************************************************************************

  public GrupoSensor() {
  }

  public char getSensor() {
    return sensor;
  }

  public void setSensor(char sensor) {
    this.sensor = sensor;
  }
  
  public Grupo getGrupo() {
    return grupo;
  }

  public void setGrupo(Grupo grupo) {
    this.grupo = grupo;
  }

  public int getId() {
    return id;
  }

  @Override
  public String toString() {
    return "GrupoSensor{" + "id=" + id + ", sensor=" + sensor + ", grupo=" + grupo + '}';
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final GrupoSensor other = (GrupoSensor) obj;
    if (this.id != other.id) {
      return false;
    }
    if (this.sensor != other.sensor) {
      return false;
    }
    if (this.grupo != other.grupo && (this.grupo == null || !this.grupo.equals(other.grupo))) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 5;
    hash = 83 * hash + this.id;
    hash = 83 * hash + this.sensor;
    hash = 83 * hash + (this.grupo != null ? this.grupo.hashCode() : 0);
    return hash;
  }

  
  
}
